package friend

import (
	"day12_12_homework/internal/models/service"
	"github.com/gin-gonic/gin"
	"net/http"
	"strconv"
)

func CreateFriend(c *gin.Context) {
	value, _ := c.Get("userId")
	id := value.(string)
	myId, _ := strconv.Atoi(id)

	yes, s := service.Yes(myId)
	if s != "" {
		c.JSON(http.StatusBadRequest, gin.H{
			"message": s,
		})
		return
	}

	c.JSON(http.StatusOK, gin.H{
		"message": "好友添加成功",
		"data":    yes,
	})

}
